// 住院收费
<template>
  <el-row class="hospitalizedCharge-content">
    <el-col :span="24">
      <el-col
        :span="24"
        class="pddTop hospitalizedCharge-right"
        style="padding: 0 10px; padding-top: 10px;overflow:hidding;"
      >
        <!-- <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
        >
          <el-menu-item index="1"><a href="#jiben">基本信息</a></el-menu-item>
          <el-menu-item index="2"><a href="#ruyuan">入院信息</a></el-menu-item>
          <el-menu-item index="3"><a href="#danbao">担保信息</a></el-menu-item>
        </el-menu> -->
           <div
          style="
    overflow: auto;"
        >

                 <el-col :span="3">

                     <el-button type="success" @click="duquinfo2">读卡</el-button>
                       <el-button type="success" @click="openUserInfo">新建</el-button>


                </el-col>
                  <el-form
              :inline="false"
              class="form-demo"
              label-width="100px"
              v-model="menfrom"
            >
                 <el-col :span="8">
                  <el-form-item label="就诊卡类型:">
                         <el-radio-group  v-model="menfrom.mdtrt_cert_type">
      <el-radio :label="'01'" >电子凭证</el-radio>
      <el-radio   :label="'02'">身份证</el-radio>
      <el-radio :label="'03'">社保卡</el-radio>
    </el-radio-group>

                  </el-form-item>
                </el-col>
                  <el-col :span="5">
                  <el-form-item label="就诊凭证号:">
                       <el-input v-model="menfrom.mdtrt_cert_no"></el-input>

                  </el-form-item>

                </el-col>
                    <el-col :span="5">

                  <el-form-item label="卡识别码:">
                     <el-input v-model="redata.card_sn"></el-input>

                  </el-form-item>
                </el-col>
              <el-col :span="3">
                <el-form-item label="异地">
                     <!-- <el-input v-model=""></el-input> -->
                  <el-checkbox v-model="redata.is_yd"></el-checkbox>
                  </el-form-item>
                  </el-col>
                 </el-form>

          <ViewTitle text="基本信息" id="jiben" @click="hospitalization" />

          <el-col :span="24" class="pddTop10">
            <el-form
              :inline="false"
              class="form-demo"
              label-width="auto"
              v-model="formuser"

            >
              <el-col :span="24">
                <el-col :span="8">
                  <el-form-item label="姓名:">
                    <div class="yisheng" style="width: 250px;">
                      <el-popover
                        placement="bottom-end"
                        v-model="visiblePatient"
                        trigger="focus"
                      >
                        <el-input
                          placeholder="姓名"
                          slot="reference"
                          v-model="formuser.name"
                          size="mini"
                          style="height:40px"
                        >

                        </el-input>
                        <el-table
                          @row-click="xuanzePatient"
                          height="300"
                          :data="
                            patientData.filter(
                              data =>
                                !formuser.name ||
                                data.name
                                  .toLowerCase()
                                  .includes(formuser.name.toLowerCase())
                            )
                          "
                        >
                          <el-table-column
                            width="50"
                            property="id"
                            label="序号"
                          ></el-table-column>

                          <el-table-column
                            width="100"
                            property="name"
                            label="姓名"
                          ></el-table-column>
                          <el-table-column
                            width="200"
                            property="id_card"
                            label="身份证"
                          ></el-table-column>

                          <el-table-column
                            width="50"
                            property="gender"
                            label="性别"
                          >
                          <template slot-scope="scope">

        {{scope.row.gender==1?'男':scope.row.gender==2?'女':'其他'}}
      </template>
                          </el-table-column>

                          <el-table-column
                            width="150"
                            property="birthday"
                            label="生日"
                          ></el-table-column>
                        </el-table>
                      </el-popover>
                    </div>

                  </el-form-item>
                </el-col>

                <el-col :span="8">
                  <el-form-item label="性别:">
                    <el-select
                      v-model="formuser.gender"
                      placeholder="请选择性别"
                      disabled
                    >
                      <el-option label="男" :value="1"></el-option>
                      <el-option label="女" :value="2"></el-option>
                      <el-option label="未知" :value="0"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="出生日期:">
                    <el-date-picker
                      v-model="formuser.birthday"
                      type="date"
                      placeholder="选择日期"
                      disabled
                    >
                    </el-date-picker>
                  </el-form-item>
                </el-col>

                <el-col :span="24">
                  <el-col :span="8">
                    <el-form-item label="年龄:">
                      <el-input
                        placeholder="请输入年龄"
                        style="width: 200px;"
                        disabled
                        v-model="formuser.age"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>

                  <el-col :span="8">
                    <el-form-item label="病人性质:">
                      <el-select
                        v-model="menfrom.member_lv"
                        placeholder="请选择病人性质"
                        disabled
                      >
                        <el-option
                          v-for="(item, index) in member_lv"
                          :key="index"
                          :label="item.name"
                          :value="item.id"
                          >{{ item.name }}</el-option
                        >
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="社保卡号:">
                      <el-input
                        placeholder="社保卡号"
                        v-model="menfrom.rightKeyValue"
                        style="width:80%"
                        disabled
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                </el-col>
              </el-col>
              <el-col :span="24">
                <el-col :span="8">
                  <el-form-item label="身份证号:">
                    <el-input
                      placeholder="身份证号"
                      v-model="formuser.id_card"

                      style="width: 200px;"
                    >

                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <!-- <el-form-item label="医保号:">
                    <el-input
                      placeholder="医保号"
                      v-model="menfrom.rightKeyValue"
                    >
                    </el-input>
                  </el-form-item> -->
                </el-col>
                <el-col :span="8">
                  <el-form-item label="移动电话:">
                    <el-input
                      placeholder="移动电话"
                      style="width:80%"
                      v-model="formuser.phone"
                      disabled
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="紧急联系电话:">
                    <el-input
                      placeholder="紧急联系电话"
                      v-model="formuser.treatmentcard"
                      style="width:80%"
                      maxlength="11"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="24">
                <el-col :span="12">
                  <el-form-item label="家庭住址:">
                    <el-input
                      placeholder="家庭住址"
                      v-model="formuser.address"
                      disabled
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="婚姻状况:">
                    <el-select
                      v-model="formuser.marriage"
                      placeholder="请选择婚姻状况"
                      disabled
                    >
                      <el-option label="未知" value="1"></el-option>
                      <el-option label="未婚" value="2"></el-option>
                      <el-option label="已婚" value="3"></el-option>
                      <el-option label="离异" value="4"></el-option>
                      <el-option label="丧偶" value="5"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="8">
                  <el-form-item label="国籍:">
                    <el-select
                      v-model="menfrom.nation"
                      placeholder="请选择国籍"
                      disabled
                    >
                      <el-option label="中国" value="0"></el-option>
                      <el-option label="俄罗斯" value="1"></el-option>
                    </el-select>
                  </el-form-item> -->
                <!-- </el-col> -->

              </el-col>
            </el-form>
          </el-col>
            <el-col :span="24">
             <el-table
        ref="singleTable"
        :data="insuinfo"
        highlight-current-row
        style="width: 100%"
        @row-click="xuaninsutype"
      >

        <el-table-column property="insutypename" label="险种类型" >
        </el-table-column>
        <el-table-column property="psn_typename" label="人员类型" >
        </el-table-column>
        <el-table-column property="cvlserv_flag" label="公务员标志">
        </el-table-column>
         <el-table-column property="emp_name" label="单位名称" >
        </el-table-column>
        <el-table-column property="paus_insu_date" label="参保日期" >
        </el-table-column>

         <el-table-column property="balc" label="余额" >
        </el-table-column>
        <el-table-column property="psn_insu_stas" label="参保状态">
        </el-table-column>
      </el-table>
                     </el-col>
          <ViewTitle text="入院信息" id="ruyuan" />
          <el-col :span="24" class="pddTop10">
            <el-form
              :inline="false"
              class="form-demo"
              label-width="auto"
              v-model="menfrom"
              :rules="rules" ref="menfrom"
            >
              <el-col :span="24">
                <!-- <el-col :span="8">
                  <el-form-item label="住院号:">
                    <el-input
                      placeholder="住院号"
                      v-model="menfrom.ipt_no"
                    >
                    </el-input>
                  </el-form-item>
                </el-col> -->
                <!-- <el-col :span="8">
                  <el-form-item label="病案号:">
                    <el-input
                      placeholder="病案号"
                      v-model="menfrom.medrcdno"
                    >
                    </el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :span="8">
                  <el-form-item label="入院方式:" prop="warrant_type">
                    <el-select
                      v-model="menfrom.warrant_type"
                      placeholder="入院方式"
                    >
                      <el-option
                        v-for="(item, index) in ruyuan"
                        :key="index"
                        :label="item.name"
                        :value="item.id"
                        >{{ item.name }}</el-option
                      >
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="入院时间:" prop="begntime">
                    <el-date-picker
                      v-model="menfrom.begntime"
                     type="datetime"
                      placeholder="选择日期"

                      value-format="yyyy-MM-dd HH:mm:ss"

                    >
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="门诊号:">
                    <el-input placeholder="门诊号" v-model="menfrom.patient_no">
                    </el-input>
                  </el-form-item>
                </el-col>
                <!-- <el-col  :span="8">
              <el-form-item label="入院病区:">
                <el-input placeholder="请输入年龄" v-model="menfrom.rightKeyValue">
                </el-input>
              </el-form-item>
            </el-col>-->
              </el-col>
              <el-col :span="24">
                <el-col :span="8">
                  <el-form-item label="入院状况:">
                    <el-select
                      v-model="menfrom.dscg_maindiag_code"
                      placeholder="入院状况"
                    >
                      <el-option
                        v-for="(item, index) in dscg_maindiag_list"
                        :key="index"
                        :label="item.name"
                        :value="item.id"
                        >{{ item.name }}</el-option
                      >
                    </el-select>
                  </el-form-item>
                </el-col>
                   <el-col :span="8">
                  <el-form-item label="医疗类别:" prop="med_type">
                    <el-select
                      v-model="menfrom.med_type"
                      placeholder="医疗类别"

                    >
                      <el-option
                        v-for="(item, index) in yiliao"
                        :key="index"
                        :label="item.name"
                        :value="item.id"
                        >{{ item.name }}</el-option
                      >
                    </el-select>

                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="入院科室:">
                    <el-cascader
                      v-model="menfrom.department_id"
                      :options="departmentoptions"
                      :props="{ label: 'name', value: 'id',checkStrictly: true }"
                      style="width:90%"
                      :show-all-levels="false"
                      clearable
                      @change="handleChange"
                    ></el-cascader>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="24">
                <!-- <el-col :span="8">
                  <el-form-item label="门诊医生:">
                    <el-select
                      v-model="menfrom.chfpdr_id"
                      placeholder="门诊医生"
                    >
                      <el-option
                        v-for="(item, index) in doctorData"
                        :key="index"
                        :label="item.real_name"
                        :value="item.number"
                        >{{ item.real_name }}</el-option
                      >
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="其他医生:">
                      <el-select
                      v-model="menfrom.other_doctor_id"
                      placeholder="其他医生"
                    >
                      <el-option
                        v-for="(item, index) in doctorData"
                        :key="index"
                        :label="item.real_name"
                        :value="item.number"
                        >{{ item.real_name }}</el-option
                      >
                    </el-select>
                  </el-form-item>
                </el-col>

                <el-col :span="8"> </el-col> -->
              </el-col>
              <el-col :span="24"> </el-col>
              <el-col :span="24">
                <el-col :span="8">
                  <el-form-item label="押金警示:">
                    <el-input
                      placeholder="押金警示"
                      v-model="menfrom.deposit_warn"
                      type='number'
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="押金底值:">
                    <el-input
                      placeholder="押金底值"
                      v-model="menfrom.deposit_min"
                      type='number'
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="押金欠费上限:">
                    <el-input
                      placeholder="押金欠费上限"
                      v-model="menfrom.deposit_max"
                      type='number'
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="8">
                  <el-form-item label="登记人:">
                    <el-input placeholder="登记人" v-model="menfrom.create_by">
                    </el-input>
                  </el-form-item>
                </el-col> -->
              </el-col>
              <el-col :span="24" v-if="!userdata.masterInfo">
                <el-col :span="12">
                  <el-form-item label="住院诊断:" width="">
                    <div class="yisheng2">
                      <el-popover
                        placement="bottom-end"
                        v-model="visiblePatient2"
                        trigger="focus"
                      >
                        <el-input
                          placeholder="住院诊断"
                          slot="reference"
                          v-model="dictname"
                          size="mini"
                          @focus="huoqu"


                          @input="getgetDiseaseDict"
                          style="height:40px"
                        >
                        </el-input>


                        <el-table
                          height="300"
                          ref="multipleTable"
                          :data="disease_list"
                          @row-click="handleSelectionChange"
                        >


                          <el-table-column
                            width="50"
                            property="id"
                            label="序号"
                          ></el-table-column>

                          <el-table-column
                          width="300"
                            property="name"
                            label="名称"
                          ></el-table-column>


                          <el-table-column
                            width="100"
                            property="code"
                            label="编码"
                          ></el-table-column>
                        </el-table>
                                  <el-pagination
                    :current-page="page2"
                    :page-size="limit2"
                    @current-change="handlePagination2"
                    :total="pageCount2"
                    layout="prev, pager, next"
                  >
                  </el-pagination>
                      </el-popover>
                    </div>

                  </el-form-item>
                  <el-table

                          ref="multipleTable"
                          :data="tableData1"

                        >


                          <el-table-column
                            width="150"
                            property="id"
                            label="序号"
                          ></el-table-column>

                          <el-table-column

                            property="name"
                            label="名称"
                          ></el-table-column>


                          <el-table-column
                            width="100"
                            property="code"
                            label="编码"
                          ></el-table-column>
                               <el-table-column  label="操作" width="120">
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="deleteRow(scope.$index, tableData1)"
                    type="text"
                    size="small"
                  >
                    移除
                  </el-button>
                </template>
              </el-table-column>
                        </el-table>
                </el-col>
                  <el-col :span="12">


                  <el-col :span="24">
                  <el-form-item label="诊断描述:">
                      <el-input placeholder="诊断描述" v-model="menfrom.adm_diag_dscr">
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="24">
                  <el-form-item label="备注:">
                    <el-input placeholder="备注" v-model="menfrom.remark">
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-col>
              </el-col>

              <el-col :span="24">
                <el-col :span="6">
                  <el-form-item label="陪护人:">
                    <el-input
                      placeholder="陪护人"
                      v-model="menfrom.family_name"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                    <el-col :span="6">
                  <el-form-item label="与患者关系:">
                    <!-- <el-input
                      placeholder="与患者关系"
                      v-model="menfrom.relationship"
                    >
                    </el-input> -->
                     <el-select
                      v-model="menfrom.relationship"
                      placeholder="与患者关系"
                    >
                      <el-option
                        v-for="(item, index) in relationship"
                        :key="index"
                        :label="item.name"
                        :value="item.id"
                        >{{ item.name }}</el-option
                      >
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="联系方式:">
                    <el-input
                      placeholder="联系方式"
                      v-model="menfrom.family_phone"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item label="紧急联系方式:">
                    <el-input
                      placeholder="紧急联系方式"
                      v-model="menfrom.family_phone2"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>


                <el-col :span="24">
                  <el-form-item label="家庭住址:">
                    <el-input
                      placeholder="家庭住址"
                      v-model="menfrom.family_address"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>

              </el-col>
            </el-form>
          </el-col>
          <ViewTitle text="担保信息" id="danbao" />
          <el-col :span="24" class="pddTop10" >
            <el-form
              :inline="false"
              class="form-demo"
              label-width="auto"
              v-model="menfrom"
            >
              <el-col :span="24">
                <el-col :span="8">
                  <el-form-item label="担保人:">
                    <el-input
                      placeholder="担保人"
                      v-model="menfrom.warrant_name"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="担保电话:">
                    <el-input
                      placeholder="担保电话"
                      v-model="menfrom.warrant_phone"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <!-- <el-col :span="8">
                  <el-form-item label="入院类型:">
                    <el-select
                      v-model="menfrom.warrant_type"
                      placeholder="入院类型"
                    >
                      <el-option label="押金" value="0"></el-option>
                      <el-option label="担保" value="1"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col> -->
                <el-col :span="8">
                  <el-form-item label="担保单位:">
                    <el-input
                      placeholder="担保单位a"
                      v-model="menfrom.warrant_company"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-col>
            </el-form>
          </el-col>
        </div>
      </el-col>
    </el-col>
    <el-dialog :close-on-click-modal='false' title="建立患者档案" :visible.sync="dialogFormVisible2" :modal='false'>
      <el-form :inline="true" :model="dialogForm" label-width="auto">
        <el-form-item label="姓名">
          <el-input v-model="dialogForm.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="身份证号">
          <el-input v-model="dialogForm.id_card"
           @blur="getInfo2(dialogForm.id_card)"
          autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-select v-model="dialogForm.gender" placeholder="">
            <el-option label="男" value="1"></el-option>
            <el-option label="女" value="2"></el-option>
            <el-option label="未知" value="0"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="病人性质:">
          <el-select v-model="dialogForm.nature" placeholder="请选择病人性质">
            <el-option
              v-for="(item, index) in member_lv"
              :key="index"
              :label="item.name"
              :value="item.id"
              >{{ item.name }}</el-option
            >
          </el-select>
        </el-form-item>
        <el-form-item label="媒介来源:">
          <el-select v-model="dialogForm.source" placeholder="请选择媒介来源">
            <el-option
              v-for="(item, index) in meijielaiyuan"
              :key="index"
              :label="item.name"
              :value="item.id"
              >{{ item.name }}</el-option
            >
          </el-select>
        </el-form-item>
        <el-form-item label="婚姻状况:">
          <el-select v-model="dialogForm.marriage" placeholder="请选择婚姻状况">
            <el-option label="未知" value="1"></el-option>
            <el-option label="未婚" value="2"></el-option>
            <el-option label="已婚" value="3"></el-option>
            <el-option label="离异" value="4"></el-option>
            <el-option label="丧偶" value="5"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="联系方式">
          <el-input
            v-model.number="dialogForm.phone"
            type="number"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="出生日期">
          <el-date-picker
            v-model="dialogForm.birthday"
            type="date"
            placeholder="选择日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="家庭地址">
          <el-input v-model="dialogForm.address" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible2 = false">取 消</el-button>
        <el-button type="success" :disabled='isDisable' @click="handelMemberSave">保 存</el-button>
      </div>
    </el-dialog>
    <!-- <el-dialog :close-on-click-modal='false' title="获取医疗机构信息" :visible.sync="dialogFormVisible">
      <el-form
        :inline="true"
        :model="orgfrom"
        label-width="auto"
        ref="orgfrom"
      >
        <el-form-item label="医药机构名称">
          <el-input
            v-model="orgfrom.name"
            prop="name"
            autocomplete="off"
          ></el-input>
        </el-form-item>

        <el-form-item label="医药机构编码">
          <el-input v-model="orgfrom.number" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="success" @click="handeSave('orgfrom')"
            >保 存</el-button
          >
        </el-form-item>
      </el-form>
    </el-dialog> -->
  </el-row>
</template>
<script>
import FromList from "@/forComponents/fromList/fromList";
import TopManu from "@/components/TopMenu";
import ViewTitle from "@/forComponents/viewTitle/index.vue";
import {
  handelMemberSave,
  getProfileList,
  getdictIndex,
  hospitalization,
  getgetDiseaseDict,
  getHospitalMember
} from "@/api/register";
import { getOrgInfo, update,getInfo,getuserinfo,getuserinfo2 } from "@/api/zhuyanre";
import { getUserList,readidcard } from "@/api/user";
import { getOrganization } from "@/api/organization";
import { getMemberIndex } from "@/api/patient";

let that;
export default {
    props: ['userdata','relationship'],
  data() {
    return {
      visiblePatient: false,
      visiblePatient2: false,
      index: 0,
      dictname: "",
      dictname2: "",
      tableTitle: [
        {
          prop: "ipt_no",
          name: "住院号",
          type: 1,
          width: "80"
        },
        {
          prop: "name",
          name: "姓名",
          type: 1,
          width: "80"
        },
        {
          prop: "id_card",
          name: "身份证",
          type: 1
        }
      ],
      currentPage: 0,
      input3: 0,
      dialogForm: {
        name: "",
        id_card: "",
        gender: "",
        phone: "",
        birthday: "",
        address: "",
        //病人性质
        nature: "",
        //婚姻状况
        marriage: "",
        //国籍
        // country:'',
        // 名族
      psn_no:'',
        //来源
        source:''
      },
      page2:1,
      limit2:15,
      pageCount2:0,
            tableData: [],
      //病人信息
      formuser: {
        // rightKeyValue: "",
        psn_no:'',
        name: "",
        age: "",
        birthday: "",
        id_card: "",
        phone: "",

        address: "",
        //就诊证号
        treatmentcard: "",
        //社保卡号
        socialcard: "",
        country: "",
        nation: "",
        id: ""
      },
      dialogFormVisible2: false,
      //提交
      menfrom: {
        member_id: 0, //病人id
        member_lv: '', //病人性质
        department_id: [0,0,0], //科室id
        dscg_maindiag_code: "", //入院状况
        adm_diag_dscr: "", //入院诊断描述
        doctor_id: "", //主治医师
        nurse_id: "", //责任护士
        begntime: "", //住院时间
        diet_id: "", //饮食种类， 数据字典  group_id: 6
        deposit_min: "", //押金底值
        chfpdr_id: 0, //门诊医生
        patient_no: "", //门诊编号
        deposit_warn: "", //押金警示
        disease_id: [], //入院诊断，诊断接口获取
        adm_diag_dscr:'',//诊断描述,
        mdtrt_cert_type:'02',//凭证,
        mdtrt_cert_no:'',//就诊凭证编号,
        nurse_level: "",
        deposit_max: "", //押金上限
        other_doctor_id: 0, //床管医生
        med_type:255,//医疗类别
        family_name: "", //家属姓名',
        family_phone: "", //家属联系方式',
        family_phone2: "", //紧急联系人',
        relationship: "", // '与患者关系',
        family_address: "", //家庭地址',
        warrant_name: "", //担保人',
        warrant_phone: "", //担保电话',
        warrant_type:35, //入院类型',
        warrant_company: "", //'担保单位',
        remark: "", //备注
        insuplc_admdvs:'',

        insutype:'',
      },
        jiuzhen:[],
      //病人性质
      member_lv: [],
      diet_list: [],
      dscg_maindiag_list: [],
      //科室
      departmentoptions: [],
      //门诊医生
      doctorData: [],
      doctorPage: 0,
      doctorSize: 10,
      huli: [],
      ruyuan: [],
      orgfrom: {
        name: "",
        number: ""
      },
         redata:{
         cert_no:'000',
         cert_type:'01',
         card_sn:'',
         member_id:'',
         is_yd:false,
       },
      activeIndex: "1",
      dialogFormVisible: false,
      disease_list: [],
      ifupdata: false,
      isDisable:false,
      patientData: [],
      rowlist: [],
      ifxuan:false,
      meijielaiyuan:[],
      yiliao:[],
      zhenduan:[],
      userztype:[],
     minzulist:[],
     usertype:[],
     insutypelist:[],
     jiesuanlist:[],
     insuinfo:[],
     tableData1:[],
    baseinfo:{},
     rules: {
        warrant_type: [
            { required: true, message: '请选择入院方式', trigger: 'change' }
          ],
          begntime: [
            { type: 'date', required: true, message: '请选择时间', trigger: 'change'}
          ],
          med_type: [
            { required: true, message: '请选择医疗类别', trigger: 'change' }
          ]
        }
    };
  },

  mounted() {
    that = this;

    that.getdiet_list();
    that.getDoctorList();

    that.getgetDiseaseDict();

    that.getOrganization();

        let date = new Date()
        let yyyy = date.getFullYear()
        let MM = (date.getMonth() + 1) < 10 ? ("0" + (date.getMonth() + 1)) : (date.getMonth() + 1)
        let dd = date.getDate() < 10 ? ("0" + date.getDate()) : date.getDate()
        let HH = date.getHours() < 10 ? ("0" + date.getHours()) : date.getHours()
        let mm = date.getMinutes() < 10 ? ("0" + date.getMinutes()) : date.getMinutes()
    var ss = date.getSeconds();
    this.menfrom.begntime=yyyy+'-'+MM+'-'+dd+' '+HH+':'+mm+':'+ss
    that.getMemberIndex();
        if (this.userdata.member) {
        this.formuser = this.userdata.member;
        this.formuser.gender = this.formuser.gender ;
        var masterInfo = this.userdata.masterInfo;
        this.menfrom.patient_no= this.userdata.nodeInfo.patient_no
        var nodeInfo = this.userdata.nodeInfo;
        var dataobj = {};
        this.ifupdata = true;
        Object.assign(dataobj, masterInfo, nodeInfo);
        var disease_id = [];
        for (let i in dataobj.disease) {
          disease_id.push(dataobj.disease[i].disease_id);
        }

        this.menfrom = {
          patient_no: dataobj.patient_no, //门诊编号
          member_id: this.formuser.id, //病人id
          member_lv: this.formuser.nature , //病人性质
          id: nodeInfo.hospital_id,
          department_id: dataobj.department_id, //科室id
          dscg_maindiag_code: dataobj.dscg_maindiag_code, //入院状况
          adm_diag_dscr: dataobj.adm_diag_dscr, //入院诊断描述
          doctor_id: dataobj.doctor.id, //主治医师
          nurse_id: dataobj.nurse.id, //责任护士
          begntime: dataobj.begntime, //住院时间
          diet_id: "", //饮食种类， 数据字典  group_id: 6
          deposit_min: dataobj.deposit_min, //押金底值
          chfpdr_id: dataobj.chfpdr_id, //门诊医生
          // insuplc_admdvs:'',
          deposit_warn: dataobj.deposit_warn, //押金警示
          disease_id: disease_id, //入院诊断，诊断接口获取

          nurse_level: dataobj.nurse_level ,

          other_doctor_id: dataobj.other_doctor_id , //床管医生

          family_name: dataobj.family_name, //家属姓名',
          family_phone: dataobj.family_phone, //家属联系方式',
          family_phone2: dataobj.family_phone2, //紧急联系人',
          relationship:dataobj.relationship, // '与患者关系',
          family_address: dataobj.family_address, //家庭地址',
          warrant_name: dataobj.warrant_name, //担保人',
          warrant_phone: dataobj.warrant_phone, //担保电话',
          warrant_type: dataobj.warrant_type+"", //入院类型',
          warrant_company: dataobj.warrant_company, //'担保单位',
          remark: dataobj.remark, //备注
          med_type:dataobj.med_type
        };
      }
    // that.ifupdata=false
  },
  watch: {

    userdata(n) {
      console.log(this.userdata, "000000");
      this.userdata = n;
      if (this.userdata.member) {
        this.formuser = this.userdata.member;
        this.menfrom.patient_no=this.userdata.nodeInfo.patient_no
        this.formuser.gender = this.formuser.gender ;
        var masterInfo = this.userdata.masterInfo;
        var nodeInfo = this.userdata.nodeInfo;
        var dataobj = {};
        this.ifupdata = true;
        Object.assign(dataobj, masterInfo, nodeInfo);
        var disease_id = [];
        if( dataobj.disease){
                for (let i in dataobj.disease) {
          disease_id.push(dataobj.disease[i].disease_id);
        }
        }
       console.log(dataobj)
        this.menfrom = {
             patient_no: dataobj.patient_no, //门诊编号
          member_id: this.formuser.id, //病人id
          member_lv: this.formuser.nature , //病人性质
          id: nodeInfo.hospital_id,
          department_id: dataobj.department_id , //科室id
          dscg_maindiag_code: dataobj.dscg_maindiag_code, //入院状况
          adm_diag_dscr: dataobj.adm_diag_dscr, //入院诊断描述
          doctor_id: dataobj.doctor.id , //主治医师
          nurse_id: dataobj.nurse.id , //责任护士
          begntime: dataobj.begntime, //住院时间
          diet_id: "", //饮食种类， 数据字典  group_id: 6
          deposit_min: dataobj.deposit_min, //押金底值
          chfpdr_id: dataobj.chfpdr_id, //门诊医生
        // insuplc_admdvs:'',
          deposit_warn: dataobj.deposit_warn, //押金警示
          disease_id: disease_id, //入院诊断，诊断接口获取

          nurse_level: dataobj.nurse_level,

          other_doctor_id: dataobj.other_doctor_id, //床管医生

          family_name: dataobj.family_name, //家属姓名',
          family_phone: dataobj.family_phone, //家属联系方式',
          family_phone2: dataobj.family_phone2, //紧急联系人',
          relationship: dataobj.relationship , // '与患者关系',
          family_address: dataobj.family_address, //家庭地址',
          warrant_name: dataobj.warrant_name, //担保人',
          warrant_phone: dataobj.warrant_phone, //担保电话',
          warrant_type: dataobj.warrant_type, //入院类型',
          warrant_company: dataobj.warrant_company, //'担保单位',
          remark: dataobj.remark, //备注
          med_type:dataobj.med_type
        };
      }
    }
    // console.log(dataobj,this.menfrom)
    // disease_id: 1, //入院诊断，诊断接口获取
  },
  methods: {
    duquinfo2(){
      if(this.menfrom.mdtrt_cert_type=='02'){
            getuserinfo().then(res=>{
          if(res.code==200){
            this.menfrom.mdtrt_cert_no=res.data.id_card
            this.formuser.id_card=res.data.id_card
            this.formuser.name=res.data.name

           this.dialogForm.address=res.data.address
           this.formuser.address=res.data.address

            this.duquinfo()
          }


        })
      }else if(this.menfrom.mdtrt_cert_type=='03'){
           getuserinfo2().then(res=>{
          // if(res.code==200){
            this.menfrom.mdtrt_cert_no=res.data.id_card
            this.menfrom.id_card=res.data.id_card
            this.formuser.id_card=res.data.id_card
          //   this.formuser.name=res.data.name

          //  this.dialogForm.address=res.data.address
          //  this.formuser.address=res.data.address
          console.log(res)
             this.redata.card_sn=res.data.social_card
            this.dialogForm.social_card=res.data.social_card
            this.duquinfo()
          // }


        })

      }



    },
     duquinfo(){
     var data_t=this.redata
     data_t.cert_type=this.menfrom.mdtrt_cert_type
     data_t.cert_no=this.menfrom.mdtrt_cert_no
     data_t.card_sn=this.redata.card_sn
     data_t.is_yd=data.is_yd?1:''
     data_t.member_id=''
   console.log(data_t)
      getInfo(data_t).then(res=>{
        if(res.code==200){
            that.baseinfo=res.data.baseinfo
             that.formuser.name=res.data.baseinfo.psn_name
             that.menfrom.psn_no=res.data.baseinfo.psn_no
             that.formuser.psn_no=res.data.baseinfo.psn_no
             that.formuser.id_card=res.data.baseinfo.certno
             that.formuser.age=res.data.baseinfo.age
             that.formuser.birthday=res.data.baseinfo.brdy
           that.formuser.gender=res.data.baseinfo.gend
           that.baseinfo.naty=this.mapminzu( that.baseinfo.naty)
           that.baseinfo.psn_cert_type=this.mapuserztype(that.baseinfo.psn_cert_type)

          that.insuinfo=res.data.insuinfo
           for (let i = 0; i < that.insuinfo.length; i++) {
           that.insuinfo[i].insutypename=this.mapxian(that.insuinfo[i].insutype)
             that.insuinfo[i].psn_typename=this.mapusertype(that.insuinfo[i].psn_type)
             that.insuinfo[i].cvlserv_flag=that.insuinfo[i].cvlserv_flag==1?'是':'否'
              that.insuinfo[i].psn_insu_stas=that.insuinfo[i].psn_insu_stas==0?'未参保':that.insuinfo[i].psn_insu_stas==1?'正常':
              that.insuinfo[i].psn_insu_stas=that.insuinfo[i].psn_insu_stas==2?'暂停':'终止'
           }
           this.getProfileList( that.formuser.id_card)
           console.log( that.insuinfo)
        }else{
          this.$message({
            message:res.message
          })
        }

      })
   },
   mapusertype(num) {
       var art = "";
         that.usertype.map(function(value,i,array){
        if (parseInt(array[i].value) == parseInt(num)) {
          art = value.name;
        }
       })
        return art;
    },
       mapxian(num) {
      var art = "";

         that.insutypelist.map(function(value,i,array){

            if (parseInt(array[i].value)  == parseInt(num)) {
          art = value.name;
        }

       })
        return art;
    },
       mapminzu(num) {
      var art = "";
      for (var i in that.minzulist) {
        if (that.minzulist[i].id == num) {
          art = that.minzulist[i].value;
        }
        return art;
      }
    },
       mapuserztype(num) {
      var art = "";
      num=parseInt(num)
      for (var i in that.userztype) {
        if (that.userztype[i].value == num) {
          art = that.userztype[i].name;
        }
        return art;
      }
    },
       xuaninsutype(row){
      this.menfrom.insutype=row.insutype
      this.menfrom.insuplc_admdvs =row.insuplc_admdvs
   },
    //
    huoqu() {
      if (
        this.dictname != "" &&
        this.dictname.charAt(this.dictname.length - 1) != "&"
      ) {
        this.dictname = this.dictname + "&";

      }
    },
    getInfo2(idCard) {
        let sex = null;
        let birth = null;
        let myDate = new Date();
        let month = myDate.getMonth() + 1;
        let day = myDate.getDate();
        let age = 0;

        if (idCard.length === 18) {
          age = myDate.getFullYear() - idCard.substring(6, 10) - 1;
          sex = idCard.substring(16, 17);
          birth = idCard.substring(6, 10) + "-" + idCard.substring(10, 12) + "-" + idCard.substring(12, 14);
          if (idCard.substring(10, 12) < month || idCard.substring(10, 12) === month && idCard.substring(12, 14) <= day)
            age++;

        }
        if (idCard.length === 15) {
          age = myDate.getFullYear() - idCard.substring(6, 8) - 1901;
          sex = idCard.substring(13, 14);
          birth = "19" + idCard.substring(6, 8) + "-" + idCard.substring(8, 10) + "-" + idCard.substring(10, 12);
          if (idCard.substring(8, 10) < month || idCard.substring(8, 10) === month && idCard.substring(10, 12) <= day)
            age++;
        }

        if (sex % 2 === 0)
          sex = 0; // 性别代码 1代表男，0代表女，暂时不涉及其他类型性别
        else
          sex = 1;
           this.dialogForm.gender=sex+''
         this.dialogForm.birthday=birth


      },
      // getBirthday(idCard) {
      //   let birthday = "";
      //   if (idCard != null && idCard !== "") {
      //     if (idCard.length === 15) {
      //       birthday = "19" + idCard.substr(6, 6);
      //     } else if (idCard.length === 18) {
      //       birthday = idCard.substr(6, 8);
      //     }
      //     birthday = birthday.replace(/(.{4})(.{2})/, "$1-$2-");
      //   }
      //    this.dialogForm.birthday=birthday
      // },
    shiqu(e){

    console.log(e)

    },
    handleSelectionChange(val) {
      this.tableData1.push(val)


    },
    handleSizeChange() {},
    handelNative() {
      // this.$router.push({path:'/workstation/registration'})
    },
    jiuzhenxuan(vla){
        console.log(vla)
    },
    //科室列表
    getOrganization() {
      getOrganization().then(res => {
        console.log(res);
        that.departmentoptions = that.deleteChildren(res.data);
      });
    },
    //删除空childern
    deleteChildren(arr) {
      let childs = arr;
      for (let i = childs.length; i--; i > 0) {
        if (childs[i].children) {
          if (childs[i].children.length) {
            this.deleteChildren(childs[i].children);
          } else {
            delete childs[i].children;
          }
        }
      }
      return arr;
    },
    handleChange(value) {
      console.log(value);
    },
    handeSave(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          getOrgInfo({ name: that.orgfrom.name, number: that.orgfrom.number })
            .then(res => {
              that.dialogFormVisible = false;
              if (res.code == 200) {
                this.$alert("查询成功", "提示", {
                  confirmButtonText: "确定"
                });
              } else {
                this.$alert(res.message, "提示", {
                  confirmButtonText: "确定"
                });
              }
            })
            .catch(e => {});
        } else {
          return false;
        }
      });
    },

    getDoctorList() {
      getUserList({
        page: that.doctorPage,
        limit: that.doctorSize,
        name: "",
        dept_id: ""
      })
        .then(res => {
          let data_t = res.data.list;
          data_t.forEach(item => {
            let arr = {
              id: item.id,

              real_name: item.real_name
            };
            that.doctorData.push(arr);
          });
        })
        .catch(e => {
          this.$message({
            message: e.message,
            type: "error"
          });
        });
    },

      getdiet_list() {
      getdictIndex({ group_id: "4,5,6,7,8,40,50,51,62,15,67,37,13,14,63" })
        .then(res => {
          let data = res.data;

          data.forEach((item, key) => {
            if(item.id==40){

             that.meijielaiyuan=item.items;
            }else if(item.id==51){

             that.chuyuanfangshi=item.items;
            }else if (item.id==2){
              that.getBuildlist=item.items
            }else if (item.id==4) {
              that.member_lv=item.items
            }else if (item.id==7) {
              that.huli=item.items
            }else if (item.id==8) {
              that.ruyuan=item.items
            }else if (item.id==6) {
              that.diet_list=item.items
            }else if (item.id==5) {
              that.dscg_maindiag_list=item.items
            }else if (item.id==62) {
              that.jiuzhen=item.items
            }else if (item.id==15) {
              that.yiliao=item.items
            }else if (item.id==67) {
              that.zhenduan=item.items
            }else if(item.id==64){

             this.userztype=item.items;
            }else if (item.id==37) {
              this.minzulist=item.items
            }else if (item.id==14 ) {
              this.usertype=item.items
            }else if (item.id==13) {
              this.insutypelist=item.items
            }else if (item.id==63) {
              this.jiesuanlist=item.items
            }



          });
        })
        .catch(e => {});

    },

      deleteRow(index, rows) {
      rows.splice(index, 1);
    },

    //计算年龄
    getage(e) {
      var birthdays = new Date(e.replace(/-/g, "/"));
      var d = new Date();
      var age =
        d.getFullYear() -
        birthdays.getFullYear() -
        (d.getMonth() < birthdays.getMonth() ||
        (d.getMonth() == birthdays.getMonth() &&
          d.getDate() < birthdays.getDate())
          ? 1
          : 0);
      return age;
    },
    getProfileList(id_card) {
      // that.index++
      getProfileList({ id_card: id_card })
        .then(res => {
          // that.index --
          let {
            name,
            id_card,
            birthday,
            phone,
            address,
            age,
            gender,
            id
          } = res.data;
          gender = `${gender}`;
          let data = {
            name,
            id_card,
            birthday,
            phone,
            address,
            age,
            gender,
            id
          };
          Object.keys(data).forEach(key => {
            that.$set(that.formuser, key, data[key]);
            // that.$set(that.dialogForm,key,data[key])
          });
        })
        .catch(e => {
          // console.log()
          // that.index --
          that.dialogFormVisible2 = true;
          that.dialogForm=that.formuser
          // that.$set(that.dialogForm, "id_card", that.formuser["id_card"]);
          this.$message({
            message: "患者信息不存在，请建立患者档案",
            type: "error"
          });
        });
    },
    //添加用户
    openUserInfo() {
      this.dialogFormVisible2 = true;
    },
    //选择用户信息
    xuanzePatient(item) {

      this.formuser.name = item.name;
      this.formuser.id = item.id;
      this.formuser.id_card = item.id_card;

      this.formuser.gender =
        this.formuser.gender == 1
          ? "男"
          : this.formuser.gender == 2
          ? "女"
          : "未知";

      this.formuser.birthday = item.birthday;
      this.formuser.age = that.getage(this.formuser.birthday);
      this.formuser.phone = item.phone;
      this.formuser.address = item.address;
       this.formuser.nation = item.nation;
      this.menfrom.member_lv=item.nature
      this.visiblePatient = false;
    },

    getMemberIndex() {
      getMemberIndex({ page: 1, limit: 10000,trace_from:'2' }).then(res => {
        that.patientData = res.data.list;
      });
    },
    handlePagination2(e){
          this.page2=e
          this.getgetDiseaseDict()
    },
    //诊断
    getgetDiseaseDict(e) {
        let d = {
        keyword: this.dictname,
         page: this.page2,
        limit: this.limit2,
      };
      getgetDiseaseDict(d)
        .then(res => {
          let data = res.data.lists;
          console.log(res);
          that.disease_list = data;
           this.pageCount2 = res.data.count;
          this.rowlist.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
        })
        .catch(e => {});
    },
    //新建病人档案卡
    handelMemberSave() {
      that.index++;
      let flag = false;
        this.dialogForm.age = that.getage(this.dialogForm.birthday);
      // Object.keys(that.dialogForm).forEach(key => {
      //   if (that.dialogForm[key] == "") {
      //     flag = true;
      //     this.$message({
      //       message: "请填写完善信息",
      //       type: "error"
      //     });
      //   }
      // });
      // if (flag) {
      //   return false;
      // }
      this.isDisable=true
       setTimeout(()=>{
           this.isDisable=false   //点击一次时隔两秒后才能再次点击
       },5000)

      var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
                if (reg.test(that.dialogForm.id_card)){


      handelMemberSave({ ...that.dialogForm })
        .then(res => {
          that.index--;
          let {
            name,
            id_card,
            birthday,
            phone,
            address,
            age,
            gender,
            id,
            nature,
            marriage,
            source
          } = res.data;
          gender = `${gender}`;
          nature = `${nature}`;
          marriage = `${marriage}`;

          this.$message({
            message: "保存成功",
            type: "success"
          });
          let data = {
            name,
            id_card,
            birthday,
            phone,
            address,
            age,
            gender,
            id,
            nature,
            marriage,
            source,
          };
          Object.keys(data).forEach(key => {
            that.$set(that.formuser, key, data[key]);
            that.$set(that.dialogForm, key, data[key]);
          });

          that.menfrom.member_lv=that.dialogForm.nature
          that.dialogFormVisible2 = false;
        })
        .catch(e => {
          that.index--;
          that.dialogFormVisible2 = false;
          this.$message({
            message: e.message,
            type: "error"
          });
        });

                }else{
                    this.$message({
            message: "身份证号不正确",
            type: "error"
          });
                }


    },

    //提交住院信息
    hospitalization() {
      var data = that.menfrom;
      data.disease_id=[]
      for(var i in this.tableData1){
            data.disease_id.push(this.tableData1[i].id)
      }

      data.disease_id = data.disease_id.toString();
      data.member_lv = that.dialogForm.nature;
      data.member_id = that.formuser.id;
      //筛选部门id

      console.log(typeof data.department_id)
      if(typeof data.department_id=='object'){
        data.department_id=data.department_id[data.department_id.length-1]
      }
      console.log(data)
      // if (that.ifupdata) {
        this.$emit("hospitalization", data, that.ifupdata);

    },
    closeitalization(){

       that.ifupdata=false
       this.rowlist= []
         that. formuser= {
        // rightKeyValue: "",
        name: "",
        age: "",
        birthday: "",
        id_card: "",
        phone: "",

        address: "",
        //就诊证号
        treatmentcard: "",
        //社保卡号
        socialcard: "",
        country: "",
        nation: "",
        id: ""
      },
          that.menfrom= {
              member_id: 0, //病人id
              member_lv: '', //病人性质
              department_id: '', //科室id
              dscg_maindiag_code: '', //入院状况
              adm_diag_dscr: "", //入院诊断描述
              doctor_id: "", //主治医师
              nurse_id: "", //责任护士
              begntime: "", //住院时间
              diet_id: "", //饮食种类， 数据字典  group_id: 6
              deposit_min: '', //押金底值
              chfpdr_id: '', //门诊医生
              patient_no: "", //门诊编号
              deposit_warn: "", //押金警示
              disease_id: [], //入院诊断，诊断接口获取

              nurse_level: "",

              other_doctor_id:0,//床管医生

              family_name:'',//家属姓名',
        family_phone:'',//家属联系方式',
        family_phone2:'',//紧急联系人',
        relationship:'',// '与患者关系',
        family_address:'',//家庭地址',
        warrant_name: '',//担保人',
        warrant_phone: '',//担保电话',
        warrant_type:  35,//入院类型',
        warrant_company:'', //'担保单位',
        remark:'',//备注

            }
    }
  },
  components: {
    FromList,
    TopManu,
    ViewTitle
  },

};
</script>

<style lang='scss' scoped>
@import "./index.scss";
</style>
